|
ARTeam Tutorial Visit:
http://cracking.accessroot.com
|
http://forum.accessroot.com |
| Information | Cracking and loader coding tutorial |
| Target |
MP3 Producer |
| Available | http://www.mp3developments.com/mp3producer.exe |
| Tools | OllyDbg 1.10 |
| Protection | Serial |
| Level | Beginner |
| Category | Cracking |
| Author(s) | ThunderPwr March 2005 |
| Requirements | Windows XP SP1, IE 5.5 and above for best viewing |
|
Introduction
|
|
|
|
1.
What we can do
|
|
Our purpose is make a loader able to run and then wait until the registration nag will be show, then enable the unlock button and push it, like you have to do when using Windows Enabler program |
|
2.
Proof of concepts
|
|
program isn't packed anyway then scan about some signature (press -> button then Plugins and finally select Krypto ANALyzer):
There
are some crypto signature, but this is not a problem trust me ;-).
more interesting you can see in the bottom right a disabled button labeled Unlock, well, first try to attack this target can be forcing enabling button with Windows Enabler and check if this can work, you can believe it, but using it make program fully registered (on next program starting nag isn't show anyway and from About menu we have a proof of it).
To restore the program state in original unregistered form just go into OllyDbg and place a breakpoint on 00488B65 and change the JNZ instruction with NOP, then press F9 and after some exception close OllyDbg.
now if you run the target this is unregistered. Keep it in mind during
your experiment (or if you prefer simply delete the file ntP2.trk
which is on System32 folder). |
|
3.
Coding a loader and source code explanation
|
|
the left branch is about CreateProcess
failure (this is when file can't be found) right branch is about right
target memory loading, next instruction block is made by one infinite
loop, inside this loop the loader made all the work needed to patch
the program and debugging application when exception was found (Switch
block).
after
CreateProcess execution target can be run freely
and related behaviour is controlled inside the main loop (with WaitForDebugEvent
and 0 time value function return every time, if you put INFINITE this
function return only if some exception is found). Main loop is made
using infinite FOR cicle, exit condition is when application stop
from user or is just patched.
in order to enable the Button, as first point, you have to know where it reside, in other word you've to find the window which contain this control, to find it we can see at the program behaviour, registration nag is the topmost window then we have to search one API function which is able to found the handle to the topmost windows, well this function can be GetForegroundWindows, from MSDN you've:
Now you've to sure about the window, to do it just check the caption and compare if it is the expected one, again you can find a suitable API, this is GetWindowText: Use
this two API to retrieve the caption of the topmost visible windows
and check if this text is equal to the registration nag, a close look
reveal a little difference from nag caption and main window caption,
for our purpose we can compare with the text "MP3Producer v 2.40"
then if comparing succeed the next step will cover the button handle
searching, in each other case just continue to loop and run the target
freely until a new caption was found.
each class window have a class name starting with # then we made a little check about it, if this check succed next step is find the right handle to refer to Unlock button, then again another API help us this means that the nag window has been created, but it is not said that all the controls in it contained are already active then to sure about it we have to look for the button, again another API help us:
now we have all the info needed to refer Unlock button, just wait some cycle to sure about all object was created and then send a WM_CREATE message to this control in order to enable it, to do it we can use the EnableWindow API function:
since we want to enable a disabled control we must use value 1 or true for bEnable parameter, for the last things we have to simulate the pushing action (like you do with Window Enabler) and this can be performed using the SendMessage API function.
this function work with window, but also a button is a window then we can use this API with a BM_CLICK message and if you search trough MSDN another interesting information can be found:
well,
this is really the end of story. |
| 4.
Conclusions |
|
Lesson Learnt
I hope this tut can be useful to learn some other patching techniques
(control enabling) other than simple patching or in-line patching,
coding a loader have some advantage, first then you don't have to
care about unpacked target, loader load it and patch directly the
unpacked code when this is loaded into process memory, second I'll
show how code it in a high level language as C++ then in a more
readable manner than direct assembly coding. Remember, a loader
can be also coded directly into the original packed executable target,
in a similar way as in-line patching. Before to run the process
you've to jump into the loader code and then execute the process
by interception of debuggin event. In this tut I've shown a loader-debugger
patcher, but there are also other way to code a loader without using
the debugger idea, in order to better know about and other stuff
about memory patching techniques read also the excellent Shub-Nigurrath
tutorial about Oraculum coding. Remember, if you plan to use this software you should purchase the product to support the authors to develop other good and best protected ;-P software. Any suggest, correction or criticism is welcome, if you need help
about this tutorial or other stuff you can reach me on ARTeam forum. |
|
Greetingz
|
|
[Support] [Groupz] |